<?php

use Biz\model\brandActivity\SmallActivity as mSmallActivity;
use Biz\model\brandActivity\SmallActivityLottery as mSmallActivityLottery;
use Doraemon\cache\UserCounter;
use Doraemon\service\User;
class ReceivedUsersAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;

    public function main()
    {
        $activityId = $this->getRequest()->getQuery('activity_id', 0);
        $info = mSmallActivity::getByWhere(['id' => $activityId]);
        $list = [];
        if ($info) {
            $uids = mSmallActivityLottery::selectByWhere(['small_activity_id' => $info['id'], 'lottery_state[!]' => mSmallActivityLottery::STATE_DEL], 'uid');
            $list = User::getUsers($uids);
            foreach ($list as $uid => &$row) {
                $count_arr = UserCounter::getOne($uid);
                $row['counter'] = ['fans' => $count_arr['fans']];
            }
            $list = ['list' => array_values($list)];
        }
        $this->setSuccess($list);
    }
}